﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style>
#div1 {width:400px; height:300px; background:#CCC; border:1px solid #999;}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>读取文件编码要与网页编码格式一样</title>
<script src="ajax.js"></script>
<script>
window.onload=function ()
{
	var aBtn=document.getElementsByTagName('input');
	var oDiv=document.getElementById('div1');
	var i=0;
	
	for(i=0;i<aBtn.length;i++)
	{
		aBtn[i].index=i;
		aBtn[i].onclick=function ()
		{
			ajax(this.index+1+'.txt', function (str){
				oDiv.innerHTML=str;
			});
		};
	}
};
</script>
</head>

<body>
<input type="button" value="按钮1" />
<input type="button" value="按钮2" />
<input type="button" value="按钮3" />
<div id="div1">
</div>
</body>
</html>
